import java.util.Arrays;

public class text56 {

public static int change(int[]arr,int amonut) {
    Arrays.sort(arr);
    swop(arr,0,arr.length-1);
    int i=0;
    int sum=0;
    for(i=0;i<arr.length;i++)
    {
        int a=amonut/arr[i];
        amonut-=a*arr[i];
        sum+=a;
        if(amonut==0)
        {
            return sum;
        }

    }
    return -1;

}
public static void swop(int[]arr,int left,int right)
{
    while(left<right)
    {
        int tmp=arr[left];
        arr[left]=arr[right];
        arr[right]=tmp;
        left++;
        right--;
    }
}






    public static void main(String[] args) {
       int[]arr={186,419,83,408};
       int a=6249;
       int c=change(arr,a);
        System.out.println(c);

    }
}
